package com.stoneframe.util.baseApp;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;

import com.stoneframe.util.baseLog.Logger;

public class ProviderHelper {
	protected static Logger logger=Logger.getLogger(ProviderHelper.class);
	/**
	 * 获取当前用户
	 */
	public static PageData getCurrentUser(){
		PageData userData=null;
		try{
			Subject currentUser=SecurityUtils.getSubject();
			Session session=currentUser.getSession();
			userData=(PageData)session.getAttribute(Const.SessionUser);
		}catch(Exception e){
			logger.error(e.toString(),e);
		}
		return userData;
	}
	
	public static boolean isSystem(){
		PageData userData=getCurrentUser();
		if(userData==null){
			return true;
		}
		return userData.get("isSystem").toString().equals("1");
	}

}
